package updatahomework;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * @classname:Exception1
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/7 16:57
 * @version: 0.1
 * @since:1.8
 */
public class Exception1 {
    public static void main(String[] args) {
        System.out.println(deom001());
    }

    public static int deom001() {
        Scanner input = new Scanner(System.in);

        int a = 0;
        int b = 0;
        while (true) {
            try {
                System.out.println("请输入第一个数字");
                a = input.nextInt();
                System.out.println("请输入第二个数字");
                b = input.nextInt();
                if (b == 0) {
                    throw new ArithmeticException("除数不能为0");
                }
                break;
            } catch (InputMismatchException e) {
                System.err.println("输入字符不匹配,必须输入一个整数.重新输入");
                input.next();
            } catch (ArithmeticException e) {
                System.err.println("除数不能为0");
            }
        }
        return a / b;
    }
}
